load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "dispatcher",
    srcs = [
        "dispatcher.go",
        "dispatcher_manager.go",
        "interface.go",
    ],
    importpath = "github.com/pingcap/tidb/disttask/framework/dispatcher",
    visibility = ["//visibility:public"],
    deps = [
        "//disttask/framework/proto",
        "//disttask/framework/storage",
        "//domain/infosync",
        "//resourcemanager/pool/spool",
        "//resourcemanager/util",
        "//sessionctx",
        "//sessionctx/variable",
        "//util",
        "//util/disttask",
        "//util/intest",
        "//util/logutil",
        "//util/syncutil",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "dispatcher_test",
    timeout = "short",
    srcs = [
        "dispatcher_test.go",
        "main_test.go",
    ],
    embed = [":dispatcher"],
    flaky = True,
    race = "off",
    shard_count = 8,
    deps = [
        "//disttask/framework/proto",
        "//disttask/framework/storage",
        "//domain/infosync",
        "//kv",
        "//testkit",
        "//testkit/testsetup",
        "//util/logutil",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//util",
        "@org_uber_go_goleak//:goleak",
    ],
)
